<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>最大值和类和</title>
</head>

<body>
    <script>
        window.onload = function(e) {
            var arry = [1, 3, 2, 4, 6, 8, 0, 1, 1, 11, 8];
            // 最大值
            var big = function(arry) {
                for (var i = 0; i < arry.length; i++) {
                    if (i == 0) {
                        var bigger = arry[i];
                    } else if (bigger > arry[i]) {
                        bigger = bigger;
                    } else {
                        bigger = arry[i];
                    }

                }

                console.log("数组" + arry + "中的最大值为：" + bigger);
            }
            big(arry);
            // 类和
            var additions = function(arry) {
                var add = 0;
                for (var i = 0; i < arry.length; i++) {
                    add = add + arry[i];
                }
                console.log("数组" + arry + "中的类和为：" + add);
            }
            additions(arry);


        }
    </script>
</body>

</html>